package com.Entity.Product;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.DAO.Product_description;
import com.Entity.Basic;

public class Description extends Basic implements Product_descriptionImplement {
	private static final long serialVersionUID = 1L;
	/**
	 * @Title Description.java
	 * @Package com.Product
	 * @author ufo
	 */

	private String description = null;
	private String descriptionId = null;

	public void save() {
		if (null != descriptionId) {
			Product_description tmp = (Product_description) databaseControler.hibernateSess
					.load(Product_description.class, descriptionId);
			tmp.setProduct_description(this.description);
			databaseControler.hibernateSess.save(tmp);
			databaseControler.commit();
		}
	}

	public Description() {
	}

	public Description(String description) {
		this.description = description;
		Product_description tmp = new Product_description();
		tmp.setProduct_description(this.description);
		databaseControler.hibernateSess.save(tmp);
		this.descriptionId = tmp.getProduct_descriptionId();
		databaseControler.commit();
	}

	public static Product_descriptionImplement load(String descriptionId) {
		Product_descriptionImplement target = new Description();
		Product_description tmp = (Product_description) databaseControler.hibernateSess
				.load(Product_description.class, descriptionId);
		target.setDescription(tmp.getProduct_description());
		target.setDescriptionId(descriptionId);
		return target;
	}

	public String getDescriptionId() {
		return descriptionId;
	}

	public void setDescriptionId(String descriptionId) {
		this.descriptionId = descriptionId;
	}

	public String toString() {
		return getDescription();
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}
